package com.crm.pojo;

import com.alibaba.fastjson.annotation.JSONField;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the DISPATCHER database table.
 */
@Entity
@NamedQuery(name = "Dispatcher.findAll", query = "SELECT d FROM Dispatcher d")
public class Dispatcher implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @SequenceGenerator(initialValue = 1, allocationSize = 1, name = "DISPATCHER_DISPATCHERID_GENERATOR", sequenceName = "SEQ2")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DISPATCHER_DISPATCHERID_GENERATOR")
    @Column(name = "DISPATCHER_ID")
    private Long dispatcherId;

    @Column(name = "DISPATCHER_IS_DEL")
    private String dispatcherIsDel;

    @Column(name = "DISPATCHER_STATE")
    private String dispatcherState;
    @Temporal(TemporalType.DATE)
    @Column(name = "FK_DISPATCHER_CUSTOMER")
    @JSONField(format = "yyyy-MM-dd")
    private Date fkDispatcherCustomer;

    @Column(name = "FK_ORDER_ID")
    private BigDecimal fkOrderId;

    //bi-directional many-to-one association to DispatcherDetail
    @OneToMany(mappedBy = "dispatcher")
    @JSONField(serialize = false)
    private List<DispatcherDetail> dispatcherDetails;

    public Dispatcher() {
    }

    public Long getDispatcherId() {
        return this.dispatcherId;
    }

    public void setDispatcherId(Long dispatcherId) {
        this.dispatcherId = dispatcherId;
    }

    public String getDispatcherIsDel() {
        return this.dispatcherIsDel;
    }

    public void setDispatcherIsDel(String dispatcherIsDel) {
        this.dispatcherIsDel = dispatcherIsDel;
    }

    public String getDispatcherState() {
        return this.dispatcherState;
    }

    public void setDispatcherState(String dispatcherState) {
        this.dispatcherState = dispatcherState;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Date getFkDispatcherCustomer() {
        return fkDispatcherCustomer;
    }

    public void setFkDispatcherCustomer(Date fkDispatcherCustomer) {
        this.fkDispatcherCustomer = fkDispatcherCustomer;
    }

    public BigDecimal getFkOrderId() {
        return this.fkOrderId;
    }

    public void setFkOrderId(BigDecimal fkOrderId) {
        this.fkOrderId = fkOrderId;
    }

    public List<DispatcherDetail> getDispatcherDetails() {
        return this.dispatcherDetails;
    }

    public void setDispatcherDetails(List<DispatcherDetail> dispatcherDetails) {
        this.dispatcherDetails = dispatcherDetails;
    }

    public DispatcherDetail addDispatcherDetail(DispatcherDetail dispatcherDetail) {
        getDispatcherDetails().add(dispatcherDetail);
        dispatcherDetail.setDispatcher(this);

        return dispatcherDetail;
    }

    public DispatcherDetail removeDispatcherDetail(DispatcherDetail dispatcherDetail) {
        getDispatcherDetails().remove(dispatcherDetail);
        dispatcherDetail.setDispatcher(null);

        return dispatcherDetail;
    }

    @Override
    public String toString() {
        return "Dispatcher{" +
                "dispatcherId=" + dispatcherId +
                ", dispatcherIsDel='" + dispatcherIsDel + '\'' +
                ", dispatcherState='" + dispatcherState + '\'' +
                ", fkDispatcherCustomer=" + fkDispatcherCustomer +
                ", fkOrderId=" + fkOrderId +
                '}';
    }
}